from PIL import Image

image_file = 'pbc17.tif'

image = Image.open(image_file).convert('L')

histo = image.histogram()
#print histo
histo_string = ''
count = 0
for i in histo:
  histo_string += str(i) + "\n"
  #print i
  #print (i+1)-i
  count = count + i
  
print(histo_string)
#print count